package com.jt.com.jt.sp02.controller;

import com.jt.sp01.entity.Item;
import com.jt.sp01.service.ItemService;
import com.jt.web.util.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
public class ItemController {
    @Autowired
    private ItemService itemService;

    @GetMapping("/{orderId}")
    public JsonResult<List<Item>> getItems(@PathVariable String orderId){
        List<Item> items=itemService.getItems(orderId);
        return JsonResult.ok().data(items);

    }
    @PostMapping("/decreaseNumber")
    public JsonResult<?> decreaseNumber(
            @RequestBody List<Item> items){
        itemService.decreaseNumber(items);
        return JsonResult.ok();

    }
}
